package compiler;

import static org.junit.Assert.*;

import org.junit.Ignore;
import org.junit.Test;

/**
 * @author Asgaroth
 *
 */

public class CompilerTest {
  
  JKlasyCompiler compiler;
  
  public CompilerTest()
  {
    this.compiler = new JKlasyCompiler();
  }
  
  @Test
  public final void testValidInputs() {
    
     String[][] inputs = 
       {{"./input/valid/test01.jkl"},
        {"./input/valid/test02.jkl"},
        {"./input/valid/test03.jkl"},
        {"./input/valid/test04.jkl"},
        {"./input/valid/test05.jkl"},
        {"./input/valid/test06.jkl"},
        {"./input/valid/test07.jkl"},
        {"./input/valid/test08.jkl"},
        {"./input/valid/test09.jkl"},
        {"./input/valid/test10.jkl"},
        {"./input/valid/test11.jkl"},
        {"./input/valid/test12.jkl"},
        {"./input/valid/test13.jkl"},
        {"./input/valid/test14.jkl"},
        {"./input/valid/test15.jkl"},
        {"./input/valid/test16.jkl"},
        {"./input/valid/test17.jkl"},
        {"./input/valid/test18.jkl"}};  
    
    for (String[] input : inputs)
    {
      System.out.println("Testing input: " + input[0]);
      assertEquals(JKlasyCompiler.EXIT_SUCCESS, compiler.compile(input));
    }
  }

  @Test 
  public final void testInvalidParsingInputs() {
    
    String[][] inputs = 
      {{"./input/invalid/parsing/test01.jkl"},
       {"./input/invalid/parsing/test02.jkl"},
       {"./input/invalid/parsing/test03.jkl"},
       {"./input/invalid/parsing/test04.jkl"},
       {"./input/invalid/parsing/test05.jkl"},
       {"./input/invalid/parsing/test06.jkl"},
       {"./input/invalid/parsing/test07.jkl"},
       {"./input/invalid/parsing/test08.jkl"},
       {"./input/invalid/parsing/test09.jkl"},
       {"./input/invalid/parsing/test10.jkl"},
       {"./input/invalid/parsing/test11.jkl"},
       {"./input/invalid/parsing/test12.jkl"},
       {"./input/invalid/parsing/test13.jkl"},
       {"./input/invalid/parsing/test14.jkl"}};
    
    for (String[] input : inputs)
    {
      System.out.println("Testing input: " + input[0]);
      assertEquals(JKlasyCompiler.EXIT_FAILURE, compiler.compile(input));
    }
  }
  
  
  @Test 
  public final void testInvalidTypingInputs() {
    
    String[][] inputs = 
      {{"./input/invalid/typing/test01.jkl"},
       {"./input/invalid/typing/test02.jkl"},
       {"./input/invalid/typing/test03.jkl"},
       {"./input/invalid/typing/test04.jkl"},
       {"./input/invalid/typing/test05.jkl"},
       {"./input/invalid/typing/test06.jkl"},
       {"./input/invalid/typing/test07.jkl"},
       {"./input/invalid/typing/test08.jkl"},
       {"./input/invalid/typing/test09.jkl"},
       {"./input/invalid/typing/test10.jkl"},
       {"./input/invalid/typing/test11.jkl"},
       {"./input/invalid/typing/test12.jkl"},
       {"./input/invalid/typing/test13.jkl"},
       {"./input/invalid/typing/test14.jkl"},
       {"./input/invalid/typing/test15.jkl"},
       {"./input/invalid/typing/test16.jkl"},
       {"./input/invalid/typing/test17.jkl"},
       {"./input/invalid/typing/test18.jkl"},
       {"./input/invalid/typing/test19.jkl"},
       {"./input/invalid/typing/test20.jkl"},
       {"./input/invalid/typing/test21.jkl"},
       {"./input/invalid/typing/test22.jkl"},
       {"./input/invalid/typing/test23.jkl"}};
    
    for (String[] input : inputs)
    {
      System.out.println("Testing input: " + input[0]);
      assertEquals(JKlasyCompiler.EXIT_FAILURE, compiler.compile(input));
    }
  }
  
  
  @Test 
  public final void testInvalidSemanticInputs() {
    
    String[][] inputs = 
      {{"./input/invalid/semantic/test01.jkl"},
       {"./input/invalid/semantic/test02.jkl"},
       {"./input/invalid/semantic/test03.jkl"},
       {"./input/invalid/semantic/test04.jkl"},
       {"./input/invalid/semantic/test05.jkl"},
       {"./input/invalid/semantic/test06.jkl"},
       {"./input/invalid/semantic/test07.jkl"},
       {"./input/invalid/semantic/test08.jkl"},
       {"./input/invalid/semantic/test09.jkl"}};
    
    for (String[] input : inputs)
    {
      System.out.println("Testing input: " + input[0]);
      assertEquals(JKlasyCompiler.EXIT_FAILURE, compiler.compile(input));
    }
  }
}
